//
//  AddPeopleAndGroupViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/3/30.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "AddPeopleAndGroupViewController.h"
#import "AddPeopleNameTableViewCell.h"
#import "FindWithConditionTableViewCell.h"
#import "FriendMessageTableViewCell.h"
#import "CeShiModelOfFriendMessage.h"
#import "CeShiModelOfGroupMessage.h"
#import "AddGroupTableViewCell.h"
#import "GroupMessageTableViewCell.h"
#import "SearchFriendViewController.h"
#import "SearchGroupViewController.h"
#import "FindPeopleWithConditionViewController.h"
#import "GroupDetailViewController.h"


@interface AddPeopleAndGroupViewController ()<UIScrollViewDelegate, UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UIScrollView *backgroudScrollView; // 背景scrollview
@property (nonatomic, strong) UITableView *findPeopleTableView; // 找人tableview
@property (nonatomic, strong) UITableView *findGroupTableView; // 找小组tableview
@property (nonatomic, strong) UIView *topWhiteView; // 顶部白色背景

@property (nonatomic, strong) UILabel *blueScrollLabel; // 滑动的蓝色label
@property (nonatomic, strong) NSMutableArray *dataArray; // 好友信息model数组
@property (nonatomic, strong) NSMutableArray *groupDataArray; // 群组信息model数组

@end

@implementation AddPeopleAndGroupViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self changeNavigation];
    //添加顶部白色背景
    [self addTopWhiteView];
    // 添加背景scrollview
    [self addBackgroudScrollView];
    // 构建一个测试用的好友信息字典
    [self addFriendDataSource];
    // 构建一个测试用的群组信息字典
    [self addGroupDataSource];
    
}

// 构建一个测试用的好友信息字典
- (void)addFriendDataSource
{
    //
    //
    NSDictionary *dicFriend1 = @{@"_friendImage": @"", @"_name": @"我叫张国文", @"_gender": @"男", @"_myID": @"987654321", @"_mark": @[@"健康达人", @"我爱看电影你呢"]};
    NSDictionary *dicFriend2 = @{@"_friendImage": @"", @"_name": @"带秋天", @"_gender": @"女", @"_myID": @"123456789", @"_mark": @[@"我是运动达人", @"爱看电影"]};
//    NSDictionary *tempDic1 = [NSDictionary dictionaryWithObjectsAndKeys:@"", @"friendImage", @"我叫张国文", @"name", @"男", @"gender", @"987654321", @"myID", nil];
//    NSDictionary *tempDic2 = [NSDictionary dictionaryWithObjectsAndKeys:@"", @"friendImage", @"带秋天", @"name", @"女", @"gender", @"123456789", @"myID", nil];
    NSMutableArray *dataArray = [NSMutableArray arrayWithObjects:dicFriend1, dicFriend2, nil];
    self.dataArray = [NSMutableArray array];
    for (NSDictionary *tempDic in dataArray) {
        CeShiModelOfFriendMessage *tempModel = [[CeShiModelOfFriendMessage alloc] init];
        [tempModel setValuesForKeysWithDictionary:tempDic];
        [self.dataArray addObject:tempModel];
    }
}

// 构建一个测试用的群组信息字典
- (void)addGroupDataSource
{
    NSDictionary *dicGroup1 = @{@"_groupImage": @"", @"_groupName": @"壹基因开发小组", @"_introduceGroup": @"该群组是为了纪念壹基因app开发3个月", @"_mark": @[@"健康小组", @"爱看电影的小组"]};
    NSDictionary *dicGroup2 = @{@"_groupImage": @"", @"_groupName": @"心脏病", @"_introduceGroup": @"该群组是对于心脏病的一个兴趣小组", @"_mark": @[@"爱出门运动的小组", @"运动小组"]};
    NSMutableArray *groupDataArray = [NSMutableArray arrayWithObjects:dicGroup1, dicGroup2, nil];
    self.groupDataArray = [NSMutableArray array];
    for (NSDictionary *tempDic in groupDataArray) {
        CeShiModelOfGroupMessage *tempModel = [[CeShiModelOfGroupMessage alloc] init];
        [tempModel setValuesForKeysWithDictionary:tempDic];
        [self.groupDataArray addObject:tempModel];
    }
    
}

// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = @"添加";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 添加顶部白色背景
- (void)addTopWhiteView
{
    self.topWhiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 50 * kAdjustParamater)];
    self.topWhiteView.userInteractionEnabled = YES;
    self.topWhiteView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_topWhiteView];
    // 找人
    UIButton *findPeopleButton = [UIButton buttonWithType:UIButtonTypeCustom];
  //  findPeopleButton.backgroundColor = [UIColor redColor];
    findPeopleButton.frame = CGRectMake((kScreenWidth / 2 - 70 * kAdjustParamater) / 2, 15 * kAdjustParamater, 70 * kAdjustParamater, 25 * kAdjustParamater);
    findPeopleButton.titleLabel.font = [UIFont systemFontOfSize:20 * kAdjustParamater];
    if ([self.friendOrGroup isEqualToString:@"friend"]) {
        [findPeopleButton setTitleColor:[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1] forState:UIControlStateNormal];
    } else {
        [findPeopleButton setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
    }
    
    [findPeopleButton setTitle:@"找人" forState:UIControlStateNormal];
    [findPeopleButton addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventTouchUpInside];
    findPeopleButton.tag = 150;
    [self.topWhiteView addSubview:findPeopleButton];
    // 找小组
    UIButton *findGroupButton = [UIButton buttonWithType:UIButtonTypeCustom];
  //  findGroupButton.backgroundColor = [UIColor redColor];
    findGroupButton.frame = CGRectMake(kScreenWidth / 2 + (kScreenWidth / 2 - 70 * kAdjustParamater) / 2, 15 * kAdjustParamater, 70 * kAdjustParamater, 25 * kAdjustParamater);
    [findGroupButton setTitle:@"找小组" forState:UIControlStateNormal];
    findGroupButton.titleLabel.font = [UIFont systemFontOfSize:20 * kAdjustParamater];
    if ([self.friendOrGroup isEqualToString:@"friend"]) {
        [findGroupButton setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
    } else {
          [findGroupButton setTitleColor:[UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1] forState:UIControlStateNormal];
    }
  
    [findGroupButton addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventTouchUpInside];
    findGroupButton.tag = 151;
    [self.topWhiteView addSubview:findGroupButton];
    
    // 添加灰色条
    UILabel *grayLine = [[UILabel alloc] initWithFrame:CGRectMake(0, self.topWhiteView.bottom - 1 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
    grayLine.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    [self.topWhiteView addSubview:grayLine];
    
    // 构建蓝色滚动条
    self.blueScrollLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.topWhiteView.bottom - 3 * kAdjustParamater, kScreenWidth / 2, 3 * kAdjustParamater)];
    self.blueScrollLabel.backgroundColor = [UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222 / 255.0 alpha:1];
    [self.topWhiteView addSubview:_blueScrollLabel];
    
}

// 点击找人变换contentoffset
- (void)changePage:(UIButton *)button
{
    switch (button.tag) {
        case 150:
        {
            NSLog(@"找人");
            [UIView animateWithDuration:0.5 animations:^{
                self.blueScrollLabel.frame = CGRectMake(0, self.blueScrollLabel.frame.origin.y, self.blueScrollLabel.frame.size.width, self.blueScrollLabel.frame.size.height);
                self.backgroudScrollView.contentOffset = CGPointMake(0, 0);
            } completion:^(BOOL finished) {
                
            }];
            UIButton *button1 = (UIButton *)[self.view viewWithTag:151];
            [button1 setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
            UIButton *button2 = (UIButton *)[self.view viewWithTag:150];
            [button2 setTitleColor:kCyanColor forState:UIControlStateNormal];
            break;
        }
            case 151:
        {
            NSLog(@"找小组");
            [UIView animateWithDuration:0.5 animations:^{
                self.blueScrollLabel.frame = CGRectMake(kScreenWidth / 2, self.blueScrollLabel.frame.origin.y, self.blueScrollLabel.frame.size.width, self.blueScrollLabel.frame.size.height);
                self.backgroudScrollView.contentOffset = CGPointMake(kScreenWidth, 0);
            } completion:^(BOOL finished) {
                
            }];
            UIButton *button1 = (UIButton *)[self.view viewWithTag:150];
            [button1 setTitleColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] forState:UIControlStateNormal];
            UIButton *button2 = (UIButton *)[self.view viewWithTag:151];
            [button2 setTitleColor:kCyanColor forState:UIControlStateNormal];

            break;
        }
        default:
            break;
    }
}

#pragma mark - 构建背景scrollview
- (void)addBackgroudScrollView
{
    
    self.backgroudScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, self.topWhiteView.bottom, kScreenWidth, kScreenHeight)];
 //   self.backgroudScrollView.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.1];
    self.backgroudScrollView.pagingEnabled = YES;
    self.backgroudScrollView.contentSize = CGSizeMake(2 * kScreenWidth, kScreenHeight);
    self.backgroudScrollView.bounces = NO;
    self.backgroudScrollView.delegate = self;
    [self.view addSubview:_backgroudScrollView];
    
    if ([self.friendOrGroup isEqualToString:@"friend"]) {
        self.backgroudScrollView.contentOffset = CGPointMake(0, 0);
        self.blueScrollLabel.frame = CGRectMake(0, self.blueScrollLabel.frame.origin.y, self.blueScrollLabel.frame.size.width, self.blueScrollLabel.frame.size.height);
    } else if ([self.friendOrGroup isEqualToString:@"group"]) {
        self.backgroudScrollView.contentOffset = CGPointMake(kScreenWidth, 0);
        self.blueScrollLabel.frame = CGRectMake(kScreenWidth / 2, self.blueScrollLabel.frame.origin.y, self.blueScrollLabel.frame.size.width, self.blueScrollLabel.frame.size.height);
    }
    
    // 添加好友tableview
    [self addFindPeopleTableView];
    // 添加小组tableview
    [self addFindGroupTableView];
}

// scrollview的delegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"滚动");
    self.blueScrollLabel.frame = CGRectMake(scrollView.contentOffset.x / 2, self.blueScrollLabel.frame.origin.y, self.blueScrollLabel.frame.size.width, self.blueScrollLabel.frame.size.height);
}

#pragma mark - 构建找人tableview
 - (void)addFindPeopleTableView
{
    self.findPeopleTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)style: UITableViewStylePlain];
    self.findPeopleTableView.dataSource = self;
    self.findPeopleTableView.delegate = self;
    self.findPeopleTableView.tag = 180;
    [self.backgroudScrollView addSubview:_findPeopleTableView];
}

#pragma mark - 构建找小组tableview
- (void)addFindGroupTableView
{
    self.findGroupTableView = [[UITableView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight) style:UITableViewStylePlain];
    self.findGroupTableView.dataSource = self;
    self.findGroupTableView.delegate = self;
    self.findGroupTableView.tag = 181;
    [self.backgroudScrollView addSubview:_findGroupTableView];
}

// tableview的代理方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (tableView.tag == 180) {
        // 说明是找人
        return 3;
    } else {
        // 说明是找小组
        return 2;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (tableView.tag == 180) {
          // 说明是找人
        if (section == 0) {
            return 1;
        } else if (section == 1) {
            return 1;
        } else {
            // 这个随着多少来确定
            return 2;
        }
    } else {
        // 说明是小组
        if (section == 0) {
            return 1;
        } else {
            // 这个随着多少来确定
            return 2;
        }
    }
}

// 返回cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 180) {
        if (indexPath.section == 0) {
            return 40 * kAdjustParamater;
        } else if (indexPath.section == 1) {
            return 54 * kAdjustParamater;
        } else if (indexPath.section == 2) {
            return 75 * kAdjustParamater;
        }
    } else {
        // 说明是小组
        if (indexPath.section == 0) {
            return 40 * kAdjustParamater;
        }
        
    }
    return 75 * kAdjustParamater;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView.tag == 180) {
        // 说明是找人
        if (indexPath.section == 0) {
            static NSString *identifier = @"addFriendCell";
            AddPeopleNameTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[AddPeopleNameTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            return cell;
        } else if (indexPath.section == 1) {
            static NSString *identifier = @"findConditonCell";
            FindWithConditionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[FindWithConditionTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.genderLabel.text = @"女、";
            cell.ageLabel.text = [NSString stringWithFormat:@"18~22岁"];
            return cell;
        } else if (indexPath.section == 2) {
            static NSString *identifier = @"friendCell";
            FriendMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[FriendMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            [cell.attentionButton addTarget:self action:@selector(clickOnCell:) forControlEvents:UIControlEventTouchUpInside];
            cell.attentionButton.tag = 190;
            [cell.addFriendButton addTarget:self action:@selector(clickOnCell:) forControlEvents:UIControlEventTouchUpInside];
            cell.addFriendButton.tag = 191;
            // 获取相应的model
            CeShiModelOfFriendMessage *model = self.dataArray[indexPath.row];
            cell.model = model;
            return cell;
        }
    } else {
        // 添加小组
        if (indexPath.section == 0) {
          static NSString *identifier = @"addGroup";
            AddGroupTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[AddGroupTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            return cell;
        } else if (indexPath.section == 1) {
            static NSString *identifer = @"GroupMessage";
            GroupMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer];
            if (cell == nil) {
                cell = [[GroupMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
            }
            [cell.attentionGroupButton addTarget:self action:@selector(clickOnCell:) forControlEvents:UIControlEventTouchUpInside];
            cell.attentionGroupButton.tag = 195;
            [cell.addGroupButton addTarget:self action:@selector(clickOnCell:) forControlEvents:UIControlEventTouchUpInside];
            cell.addGroupButton.tag = 196;
            // 获取model
            cell.model = self.groupDataArray[indexPath.row];
            return cell;
        }
    }
    
    return nil;
    
}

#pragma mark - 获取cell上面button的点击事件
- (void)clickOnCell:(UIButton *)button
{
    // 获取cell的位置
    UIView *v = [button superview];
    FriendMessageTableViewCell *cell = (FriendMessageTableViewCell *)[v superview];
    NSIndexPath *tempIndexpath = [self.findPeopleTableView indexPathForCell:cell];
    switch (button.tag) {
        case 190:
        {
          //  说明是关注好友
            NSLog(@"关注好友, row = %ld", tempIndexpath.row);
            break;
        }
            case 191:
        {
            // 说明是添加好友
            NSLog(@"添加好友,row = %ld", tempIndexpath.row);
            break;
        }
            case 195:
        {
            // 说明是关注小组
            NSLog(@"关注小组,row = %ld", tempIndexpath.row);
            break;
        }
            case 196:
        {
            // 说明是添加小组
            NSLog(@"申请入组,row = %ld", tempIndexpath.row);
            break;
        }
        default:
            break;
    }
}

// 返回分区视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (tableView.tag == 180) {
        if (section == 0) {
            return nil;
        } else if (section == 1) {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222/ 255.0 alpha:1];
            
            UIImageView *teShuXuanXiang = [[UIImageView alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, 1 * kAdjustParamater, 18 * kAdjustParamater, 18 * kAdjustParamater)];
            teShuXuanXiang.image = [UIImage imageNamed:@"teshuxuanxiao"];
            [tempView addSubview:teShuXuanXiang];
            UILabel *teShuXuanXiangLabel = [[UILabel alloc] initWithFrame:CGRectMake(teShuXuanXiang.right + 4 * kAdjustParamater, 4 * kAdjustParamater, 70 * kAdjustParamater, 12 * kAdjustParamater)];
            teShuXuanXiangLabel.text = @"特殊选项";
            teShuXuanXiangLabel.textColor = [UIColor whiteColor];
            teShuXuanXiangLabel.font = [UIFont systemFontOfSize:13 * kAdjustParamater];
            [tempView addSubview:teShuXuanXiangLabel];
            return tempView;
        } else {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222/ 255.0 alpha:1];
            UIImageView *teShuTuiJian = [[UIImageView alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, 1 * kAdjustParamater, 18 * kAdjustParamater, 18 * kAdjustParamater)];
            teShuTuiJian.image = [UIImage imageNamed:@"teshutuijian-tianjia"];
            [tempView addSubview:teShuTuiJian];
            UILabel *teShuTuiJianLabel = [[UILabel alloc] initWithFrame:CGRectMake(teShuTuiJian.right + 4 * kAdjustParamater, 4 * kAdjustParamater, 70 * kAdjustParamater, 12 * kAdjustParamater)];
            teShuTuiJianLabel.text = @"特殊推荐";
            teShuTuiJianLabel.textColor = [UIColor whiteColor];
            teShuTuiJianLabel.font = [UIFont systemFontOfSize:13 * kAdjustParamater];
            [tempView addSubview:teShuTuiJianLabel];
            
            
            return tempView;
        }
    }
     // 说明是找小组
    if (section == 0) {
        return nil;
    }
   
    UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 20 * kAdjustParamater)];
    tempView.backgroundColor = [UIColor colorWithRed:84 / 255.0 green:199 / 255.0 blue:222/ 255.0 alpha:1];
    UIImageView *teShuTuiJian = [[UIImageView alloc] initWithFrame:CGRectMake(18 * kAdjustParamater, 1 * kAdjustParamater, 18 * kAdjustParamater, 18 * kAdjustParamater)];
    teShuTuiJian.image = [UIImage imageNamed:@"tuijianxiaozu-tianjia"];
    [tempView addSubview:teShuTuiJian];
    UILabel *teShuTuiJianLabel = [[UILabel alloc] initWithFrame:CGRectMake(teShuTuiJian.right + 4 * kAdjustParamater, 4 * kAdjustParamater, 70 * kAdjustParamater, 12 * kAdjustParamater)];
    teShuTuiJianLabel.text = @"小组推荐";
    teShuTuiJianLabel.textColor = [UIColor whiteColor];
    teShuTuiJianLabel.font = [UIFont systemFontOfSize:13 * kAdjustParamater];
    [tempView addSubview:teShuTuiJianLabel];
    return tempView;
}

// 返回分区的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (tableView.tag == 180) {
        if (section == 0) {
            return 0;
        } else {
             return 20 * kAdjustParamater;
        }
        
    }
    // 说明是小组
    if (section == 0) {
        return 0;
    }
    return 20;
}

#pragma mark - cell的点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 取消阴影
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    if (tableView.tag == 180) {
        if (indexPath.section == 0) {
            // 输入好友名字
            NSLog(@"输入好友名字");
            SearchFriendViewController *searchFriendVC = [[SearchFriendViewController alloc] init];
            UINavigationController *tempNaVC = [[UINavigationController alloc] initWithRootViewController:searchFriendVC];
            [self presentViewController:tempNaVC animated:YES completion:nil];
        } else if (indexPath.section == 1) {
            // 按条件搜索
            NSLog(@"按条件搜索");
            FindPeopleWithConditionViewController *findPeopleVC = [[FindPeopleWithConditionViewController alloc] init];
            [self.navigationController pushViewController:findPeopleVC animated:YES];
        } else {
            // 进入好友详情
            NSLog(@"进入好友详情");
        }
    } else if (tableView.tag == 181) {
        if (indexPath.section == 0) {
            NSLog(@"输入小组名字");
            SearchGroupViewController *searchGroupVC = [[SearchGroupViewController alloc] init];
            UINavigationController *tempNaVC = [[UINavigationController alloc] initWithRootViewController:searchGroupVC];
            [self presentViewController:tempNaVC animated:YES completion:nil];
        } else {
            NSLog(@"进入小组详情");
            GroupDetailViewController *groupDetail = [[GroupDetailViewController alloc] init];
            [self.navigationController pushViewController:groupDetail animated:YES];
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
